﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;

public partial class Pages_Dashboard_Dashboard : System.Web.UI.Page, ICrumbedPage
{
	protected BO.User User;
	protected void Page_Load(object sender, EventArgs e)
	{
		Authenicate();
		ucProfileMenu.User = User;
		if (!IsPostBack)
			LoadData();
	}

	private void LoadData()
	{
		if(!User.ProfileID.HasValue)
			Response.Redirect(AppParams.URLs.PersonalDashboard);
		BO.Profile profile = BLL.Profiles.GetByID(User.ProfileID.Value);
		ltrProfileName.Text = profile.Name;
        
		repAccounts.DataSource = Logic.BusinessLogic.Stats.GetMasterAcountsOverview(profile.ID);
		repAccounts.DataBind();

		
	}

	

	private void Authenicate()
	{
		if (Authentication.IsCurrentUserAuthenticated())
			User = Authentication.GetCurrentUser();

		if (User == null)
			Response.Redirect("/default.aspx");
	}

	#region ICrumbedPage Members

	public int Level
	{
		get
		{
			return 1;
		}	
	}

	public string TailName
	{
		get
		{
			return "Dashboard";
		}		
	}

	#endregion
}